﻿using System.ComponentModel;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Shapes;

namespace EquipmentPanelTest
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window, INotifyPropertyChanged
    {
        public MainWindow()
        {
            InitializeComponent();

            DataContext = this;

            //var gf = new StubGalaxyFactory(1);
            //var g = gf.Create();
        }

        #region INotifyPropertyChanged Members

        public event PropertyChangedEventHandler PropertyChanged;

        private void OnPropertyChanged(string propertyName)
        {
            if (PropertyChanged != null)
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
        }

        #endregion

        private void Ellipse_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            var pos = e.GetPosition(LayoutRoot);
            UpdateNavMark(pos);
        }

        private void UpdateNavMark(Point p)
        {
            if (navCursor == null)
            {
                navCursor = new Ellipse()
                {
                    Width = 6,
                    Height = 6,
                    Fill = new SolidColorBrush(Colors.Red)
                };

                LayoutRoot.Children.Add(navCursor);
            }

            Canvas.SetTop(navCursor, p.Y - navCursor.Height / 2);
            Canvas.SetLeft(navCursor, p.X - navCursor.Width / 2);
        }

        private Ellipse navCursor;
    }
}
